// ignore_for_file: constant_identifier_names

// enum Status { SUCCESS, ERROR,}

class CommonResult {
  static const int _CODE_SUCCESS = 200;

  int? code;
  Object? data;
  String? msg;
  String? traceId;

  CommonResult.from(Map<String, dynamic> map) {
    if (map['code'] != null) {
      code = map['code'];
    } else {
      code = _CODE_SUCCESS;
    }

    data = map;
    if (map['msg'] != null) {
      msg = map['msg'];
    } else if (map['message'] != null) {
      msg = map['message'];
    }

    // traceId = map['traceId'];
  }

  bool get isSuccess => code == _CODE_SUCCESS;

  // WowResponse.completed(this.data) : code = Status.SUCCESS;
  // WowResponse.error(this.exception) : code = Status.ERROR;

  @override
  String toString() {
    return 'Status : $code \n Msg : $msg \n Data : $data \n tradeId : $traceId';
  }
}
